/*
 *  connector.h
 *  framework
 *
 *  Created by gerhard gubler on 29.11.09.
 *  Copyright 2009 md80.ch . All rights reserved.
 *
 */

#ifndef CONNECTOR_H
#define CONNECTOR_H

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <signal.h>
#include <string>
#include <netdb.h>



#define PORT "3490"  // the port users will be connecting to
#define SERVERPORT "4950"    // the port users will be connecting to
#define MYPORT "4950"    // the port users will be connecting to
#define MAXBUFLEN 1024


#define BACKLOG 10     // how many pending connections queue will hold
#define MAXDATASIZE 1024 // max number of bytes we can get at once 

using std::string;

class connector
{	
	int sockfd;
    struct addrinfo hints, *servinfo, *p;
    int rv;
    int numbytes;
    struct sockaddr_storage their_addr;
    char buf[MAXBUFLEN];
	socklen_t addr_len;
    char s[INET6_ADDRSTRLEN];
	
	string reply;
	void sigchld_handler(int );
	public:
	void *get_in_addr(struct sockaddr *);
	int sender();
	int receiver();
	string listener();
	string get();
	int talker();
};

#endif
